;(function(){
  'use strict';
  angular.module('controllers.omdisplay.recAbnormal')
    .controller('fileDetailCtrl',fileDetailCtrl)
    .controller('fileStatViewCtrl',fileStatViewCtrl);

  function fileDetailCtrl($scope,COREDATA,FDSelectorService,FDQueryParamService){
    $scope.exportUrl = COREDATA.FORMPREFIX+'OMdisplay/reconciliationsAbnormal/fileDetailExport';
    $scope.selector = FDSelectorService.selector;
    $scope.flag = FDQueryParamService.initFlag();
    $scope.date = FDQueryParamService.initDate();
    $scope.fileDetail = FDQueryParamService.initParam();
    $scope.getFileDetail = FDQueryParamService.queryFn;

    $scope.$watch('fileDetail.timeType',function(newValue,oldValue){
      if(newValue === oldValue){
        return;
      }
      $scope.date = FDQueryParamService.initDate();
    },true);

    $scope.$on('formInvalid',function(eo,flag){
      $scope.quarterInvalid = flag;
    });   
  }

  fileDetailCtrl.$inject = ['$scope','COREDATA','FDSelectorService','FDQueryParamService'];

  function fileStatViewCtrl($scope,FDViewObjService){
    $scope.viewObj = FDViewObjService.initViewObj();
    FDViewObjService.initChart();

    // $scope.getMoreDetail = function(keyCode){
    //   if(!responded){ 
    //     return;
    //   } else {
    //     responded = false;
    //     $scope._loading.show = false;
    //     if($scope.provincial) {
    //       param.provinceCode = keyCode;
    //     }else{
    //       param.channelCode = keyCode;
    //     }
    //     param.page = {
    //       currentPage: 1,
    //       pageSize: 10
    //     };
    //     FileDetailServer.moreFileDetail(param,function(res){
    //       if(res.state === '10000' && res.data.length >= 1){
    //         $scope.showDetail = true;
    //         $scope.toggle.isFolded = false;
    //         $scope.$broadcast('toDetail',res.data,res.totalCount,param);
    //         $scope._loading.show = false;
    //         responded = true;
    //       }else{
    //         $scope._loading.show = false;
    //         CoreService.dialog(res.state);
    //       }
    //     });
    //   }
    // };
    
  }

  fileStatViewCtrl.$inject = ['$scope','FDViewObjService'];

})();

// 文件对账详情点击下钻 目前需求不明
// ;(function(){
//   'use strict';
//   angular.module('controllers.omdisplay.recAbnormal')
//     .controller('fileDetailViewCtrl',fileDetailViewCtrl);

//   function fileDetailViewCtrl($scope,FileDetailServer,CoreService){
//     $scope.$on('toDetail',function(d,data,totalCount,param){
//       $scope.totalCount = totalCount;
//       $scope.param = param;
//       $scope.details = data;
//     });

//     $scope.turnToPage = function(param){
//       $scope._loading.show = true;
//       FileDetailServer.moreFileDetail(param,function(res){
//         if(res.state === '10000' && res.data.length >= 1){
//           $scope.toggle.isFolded = false;
//           $scope.totalCount = res.totalCount;
//           $scope.details = res.data;
//           $scope._loading.show = false;
//         }else{
//           $scope._loading.show = false;
//           CoreService.dialog(res.state);
//         }
//       });
//     };
//   }

//   fileDetailViewCtrl.$inject = ['$scope','FileDetailServer','CoreService'];
// })();
